const { merge } = require('webpack-merge')
const common = require('./webpack.common')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')

module.exports = merge(common, {
  mode: 'production',
  output: {
    filename: 'js/bundle.[contenthash:6].js'// 设置hash值 并将文件放置在dist/js下
  },
  devtool: false,
  plugins: [
    new CleanWebpackPlugin(),
    new CopyWebpackPlugin({
      patterns: [
        'public'
      ]
    }),
    new MiniCssExtractPlugin({
      filename: '[name]-[contenthash:6].bundle.css'
    }),
  ]
})